home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gtlayout.lha
/
Source
/
LT_SetAttributes.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-09
|
33KB
|
1,527 lines
/*
** GadTools layout toolkit
**
** Copyright © 1993-1998 by Olaf `Olsen' Barthel
** Freely distributable.
**
** :ts=4
*/
#ifndef _GTLAYOUT_GLOBAL_H
#include "gtlayout_global.h"
#endif
/*****************************************************************************/
#include <stdarg.h>
/*****************************************************************************/
#include "Assert.h"
/*****************************************************************************/
VOID
LT_SetAttributes(LayoutHandle *handle,LONG id,...)
{
va_list VarArgs;
va_start(VarArgs,id);
LT_SetAttributesA(handle,id,(struct TagItem *)VarArgs);
va_end(VarArgs);
}
/*****************************************************************************/
VOID
LTP_AddAllAndRefreshThisGadget(LayoutHandle *Handle,struct Gadget *Gadget)
{
AddGList(Handle->Window,Handle->List,(UWORD)-1,(UWORD)-1,NULL);
RefreshGList(Gadget,Handle->Window,NULL,1);
}
VOID
LTP_FixState(LayoutHandle *Handle,BOOL State,struct Gadget *Gadget,UWORD Bit)
{
if(Gadget)
{
LTP_StripGadgets(Handle,Handle->List);
if(State)
Gadget->Flags |= Bit;
else
Gadget->Flags &= ~Bit;
LTP_AddAllAndRefreshThisGadget(Handle,Gadget);
}
}
BOOL
LTP_NotifyPager(LayoutHandle *Handle,LONG ID,LONG Page)
{
if(ID != -1)
{
LT_SetAttributes(Handle,ID,
LAGR_ActivePage,Page,
TAG_DONE);
if(Handle->Failed)
return(FALSE);
}
return(TRUE);
}
/*****************************************************************************/
/****** gtlayout.library/LT_SetAttributesA ******************************************
*
* NAME
* LT_SetAttributesA -- Change object attributes
*
* SYNOPSIS
* LT_SetAttributesA(Handle,ID,Tags);
* A0 D0 A1
*
* VOID LT_SetAttributes(LayoutHandle *,LONG,struct TagItem *);
*
* LT_SetAttributes(Handle,ID,...);
*
* VOID LT_SetAttributes(LayoutHandle *,LONG,...);
*
* FUNCTION
* This routine passes the tag item list it gets directly
* over to GT_SetGadgetAttrsA(), so any tag items valid for
* gadtools.library can be used here as well. Some filtering
* may be done in order to stop objects from getting redrawn
* if this is not absolutely necessary.
*
* INPUTS
* Handle - Pointer to LayoutHandle.
*
* ID - ID number of the object to change. This is the same value
* you passed via LA_ID to LT_New() when you created this object.
*
* Tags - Attributes controlling object states.
*
*
* All gadtools.library tags are allowed, but not all are supported.
* In addition to these tags a few additional tag values are
* supported:
*
* LAHN_AutoActivate (BOOL) - Set to TRUE if you want the interface
* to always keep a string gadget active if possible. Hitting
* the return key will then cause the next following string
* gadget to get activated, either cycling through all the
* string gadgets available or stopping at the next string
* gadget to have the LAST_LastGadget attribute set.
*
* LAHN_UserData (APTR) - Store user specific data in the
* LayoutHandle->UserData entry. (V9)
*
* LAHN_RawKeyFilter (BOOL) - Discard unprocessed IDCMP_RAWKEY
* events. (V13)
* Default: TRUE
*
* LAHN_LocaleHook (struct Hook *) - The hook to call when
* locale string IDs are to be mapped to strings. The
* hook function is called with the following parameters:
*
* String = HookFunc(struct Hook *Hook,struct LayoutHandle *Handle,
* D0 A0 A2
* LONG ID)
* A1
*
* The function is to look up the string associated with the ID
* passed in and return the string.
*
* LAHN_ExitFlush (BOOL) - When the LayoutHandle is finally disposed
* of with LT_DeleteHandle() all variables maintained by the
* input handling code will be flushed. For example, if you
* would use the LA_STRPTR tag for STRING_KIND objects the
* last string gadget contents would be copied into the buffer
* pointed to by LA_STRPTR. If you do not want to use this
* feature, disable it with "LAHN_ExitFlush,FALSE". (V9)
* Default: TRUE
*
* GAUGE_KIND:
*
* LAGA_Percent (LONG) - Percentage of the gauge to fill.
*
* LAGA_InfoText (STRPTR) - Text to be printed within the
* gauge display, such as a percentage number.
*
* BOX_KIND:
*
* LABX_Index (LONG) - The number of the line to change, this
* tag works in conjunction with the LABX_Text tag.
*
* LABX_Text (STRPTR) - The text to put into the line indicated
* by the LABX_Index tag.
* As of v26 the LABX_Index tag may be omitted, the library
* will then assume the line index will be 0.
*
* LABX_Lines (STRPTR *) - The text to set for the box contents,
* terminate the text array with NULL.
*
* HORIZONTAL_KIND:
* VERTICAL_KIND:
*
* LAGR_ActivePage (LONG) - Index number of page to display
* within the group.
*
* NOTE: requires that this group was created
* with the LAGR_ActivePage attribute set.
*
* INTEGER_KIND:
*
* LAIN_Min (LONG) - Minimum allowed value for this
* object.
*
* LAIN_Max (LONG) - Maximum allowed value for this
* object.
*
* LISTVIEW_KIND:
*
* LALV_Selected (LONG) - Combines GTLV_Selected and
* GTLV_Top (for Kickstart V37) or GTLV_MakeVisible
* (for Kickstart V39 and greater). This means, the
* list display will be changed in order to show
* the item to be selected. (V34)
*
* LEVEL_KIND:
*
* LAVL_NumTicks (WORD) - Number of tick marks to draw
* next to the slider body.
*
* PASSWORD_KIND:
*
* LAPW_String (STRPTR) - Secret text to use
*
* POPUP_KIND
*
* LAPU_Labels (STRPTR *) - To block access to the popup
* menu, for example before you free the current list
* of labels, you can pass ~0 as the list parameter. (V25)
*
* STRING_KIND:
*
* LAST_CursorPosition (LONG) - Repositions the cursor,
* pass -1 to move it to the end of the string. (V7)
*
* TAPEDECK_KIND:
*
* LATD_Pressed (BOOL) - TRUE to make this button shown
* as pressed, FALSE to show it in depressed state.
*
* BOOPSI_KIND:
*
* All tags are passed straight through to SetGadgetAttrs(..).
*
* All objects:
*
* LA_LabelText (STRPTR) - New gadget label text to use.
*
* LA_LabelID (LONG) - Locale text ID to use for this object.
*
* RESULT
* none
*
* SEE ALSO
* gadtools.library/GT_SetGadgetAttrsA()
* intuition.library/SetGadgetAttrsA
*
******************************************************************************
*
*/
VOID LIBENT
LT_SetAttributesA(REG(a0) LayoutHandle *handle,REG(d0) LONG id,REG(a1) struct TagItem *TagList)
{
if(handle && TagList)
{
struct Gadget *Gadget = NULL;
struct TagItem *ThisTag,*ThisList = TagList;
ObjectNode *Node = NULL;
while(ThisTag = NextTagItem(&ThisList))
{
switch(ThisTag->ti_Tag)
{
case LH_AutoActivate:
handle->AutoActivate = ThisTag->ti_Data;
break;
case LH_RawKeyFilter:
handle->RawKeyFilter = ThisTag->ti_Data;
break;
case LH_UserData:
handle->UserData = (APTR)ThisTag->ti_Data;
break;
case LH_ExitFlush:
handle->ExitFlush = ThisTag->ti_Data;
break;
case LH_LocaleHook:
handle->LocaleHook = (struct Hook *)ThisTag->ti_Data;
break;
case LAPR_Gadget:
Gadget = (struct Gadget *)ThisTag->ti_Data;
break;
case LAPR_Object:
Node = (ObjectNode *)ThisTag->ti_Data;
break;
}
}
if(Node)
Gadget = Node->Host;
else
{
if(Gadget)
{
if(Node = (ObjectNode *)Gadget->UserData)
{
if(Node->Host != Gadget || Node->PointBack != Node)
Node = NULL;
}
}
}
if(!Gadget)
{
if(Gadget = LTP_FindGadget(handle,id))
{
if(Node = (ObjectNode *)Gadget->UserData)
{
if(Node->Host != Gadget || Node->PointBack != Node)
Node = NULL;
}
}
else
Node = LTP_FindNode(handle,id);
}
if(Node)
{
STATIC const Tag Filter[2] = { GA_Disabled,TAG_DONE };
struct TagItem *NewTags = NULL;
ULONG Exclude = NULL;
switch(Node->Type)
{
#ifdef DO_PASSWORD_KIND
{
case PASSWORD_KIND:
if(ThisTag = F